package rg.edu.ap.web.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import rg.edu.ap.po.Merchant;
import rg.edu.ap.po.User;
import rg.edu.ap.service.MerchantService;

@Controller
public class MerchantController {
	
	@Autowired
	private MerchantService merchantservice;
	
	@RequestMapping("/merlogin.action")
	public String goMerchantlogin() {
	   return "merchantlogin";
	}
	
	@RequestMapping("/mermain.action")
	public String goMermain() {
	   return "mermain";
	}
	
	@RequestMapping("/mervicinity.action")
	public String goMerVicinity() {
	   return "merVicinity";
	}
	
	@RequestMapping("/merpage.action")
	public String goPage() {
	   return "merpage";
	}
	
	@RequestMapping("/merregister.action")
	public String goMerchantregister() {
	   return "merchantregister";
	}
	
	@RequestMapping("/bathmap")
	public String goBathmap() {
	   return "bathmap";
	}
	
	@RequestMapping("/addmer.action")
	public String addUser(Merchant merchant) {
		merchantservice.addMerchant(merchant);
	   return "mermain";
	}
	
	@RequestMapping("/merlogincheck.action")
	public String loginMerchants(Merchant merchant,HttpSession session) {
		Merchant mc = merchantservice.loginMerchant(merchant);
		System.out.println(mc.getMername());
		if(mc!=null) {
			session.setAttribute("USER_SESSION_MER", mc);
		}
	   return "mermain";
	}
}
